package com.yitiao.data_algorithms.leetcode.editor.cn;
import java.util.Arrays;

class AssignCookies{
    // 2023-02-20 17:02:36
    public static void main(String[] args) {
        Solution solution = new AssignCookies().new Solution();
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int findContentChildren(int[] g, int[] s) {
        if (s.length==0)return 0;
        int ans = 0;
        Arrays.sort(g);
        Arrays.sort(s);
        int si = 0;
        for (int i = 0; i < g.length; i++) {
            while (s[si]<g[i]){
                si++;
                if (si>=s.length){
                    return ans;
                }
            }
            ans++;
            si++;
            if (si>=s.length){
                return ans;
            }
        }
        return ans;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}